package com.kaifamiao.www.demo.do0824;

import java.util.Calendar;
import java.util.Date;

public class Demo02 {
    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();
        System.out.println(calendar.toInstant());

        //将月份往前/后 推
//        calendar.add(Calendar.MONTH,-10);
        //设置此未定义的所有日历字段值和时间值
//        calendar.clear(Calendar.YEAR);
        //指示一天中的小时。
//        calendar.set(Calendar.HOUR_OF_DAY,16);
        System.out.println(calendar.toInstant().toString());
        System.out.println(calendar.get(Calendar.YEAR));
        System.out.println(calendar.get(Calendar.MONTH));
        System.out.println(calendar.get(Calendar.DATE));
        System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
        //十二时
        System.out.println(calendar.get(Calendar.HOUR));
        //二十四时
        System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
        System.out.println(calendar.get(Calendar.MINUTE));
        System.out.println(calendar.get(Calendar.SECOND));
        System.out.println(calendar.get(Calendar.MILLISECOND));
        System.out.println(calendar.get(Calendar.WEEK_OF_MONTH));
        System.out.println(calendar.get(Calendar.WEEK_OF_YEAR));
        System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
        System.out.println(calendar.get(Calendar.DAY_OF_YEAR));
        System.out.println(calendar.getActualMaximum(Calendar.MONTH));
        System.out.println(calendar.getCalendarType());
        System.out.println(calendar.getFirstDayOfWeek());

        //Calendar --> Date
        Date date = calendar.getTime();
        Date.from(calendar.toInstant());

        // Date --> Calendar
        Date date1 = new Date(1000L * 60 * 60 * 24 * 365 * 52 + 1000L * 60 * 60 * 30 * 8);
        Calendar c = Calendar.getInstance();
        c.setTime(date1);
        System.out.println(date1);
        System.out.println(c.toInstant().toString());
    }
}
